package net.similarsu.device.sdk.utils;

/**
 * a utils for channel
 */
public abstract class ChannelUtils {
    /**
     * change word 2 digest
     * @param d
     * @param startChan
     * @return
     */
    public static int word2Digest(String d, byte startChan){
        return Integer.parseInt(d.replaceAll("D0?",""))-1+startChan;
    }

    /**
     * change digest 2 word
     * @param chanId
     * @param startChan
     * @return
     */
    public static String digest2Word(int chanId, byte startChan){
        String temp =String.valueOf(chanId-startChan+1);
        if(temp.length()==1){
            temp="0"+temp;
        }
        return "D"+temp;
    }
}
